import router from "./router";
import useTokenStore from "./stores/token";


const whiteList = ['/login','/register', '/404'] // 白名单
router.beforeEach((to, from, next) => {
const {getToken} = useTokenStore();
    if(getToken()){
        if(to.path === '/login'){
            next('/')
        }else{
            next()
        }
    }else{
        if(whiteList.includes(to.path)){
            next()
        }else{
            next('/login')
        }
    }
});